var a = getApp();

Page({
    data: {
        language: "",
        isLoadMore: !0,
        page: 1,
        total_page: 0,
        recordsList: [],
        moreDataType: 1,
        recordsTeamList: [],
        trans: ""
    },
    onLoad: function(a) {
        this.getRecordsListData();
    },
    getRecordsListData: function() {
        var t = this, e = a.getNetAddresss("plugin.interval-consumption.Frontend.controllers.records.index");
        t.data.isLoadMore = !0, t.data.page = 1, t.data.total_page = 0, a._postNetWork({
            url: e,
            showToastIn: !1,
            data: {
                page: t.data.page
            },
            success: function(a) {
                var e = a.data;
                1 == e.result ? (t.data.isLoadMore = !0, t.data.total_page = e.data.list.last_page, 
                t.data.total_page || (t.data.total_page = 0), e.data.info && e.data.info.trans && wx.setNavigationBarTitle({
                    title: e.data.info.trans
                }), t.setData({
                    recordsList: e.data.list.data,
                    info: e.data.info
                })) : wx.showToast({
                    icon: "none",
                    title: e.msg,
                    duration: 1500
                });
            },
            fail: function(a) {}
        });
    },
    tabHandel: function(a) {
        var t = a.detail.index;
        this.data.moreDataType = t + 1, 1 == this.data.moreDataType ? this.getRecordsListData() : 2 == this.data.moreDataType && this.getRecordsTeamList();
    },
    getRecordsTeamList: function() {
        var t = this, e = a.getNetAddresss("plugin.interval-consumption.Frontend.controllers.records.team-records");
        t.data.isLoadMore = !0, t.data.page = 1, t.data.total_page = 0, a._postNetWork({
            url: e,
            showToastIn: !1,
            data: {
                page: t.data.page
            },
            success: function(a) {
                var e = a.data;
                1 == e.result ? (t.data.isLoadMore = !0, t.data.total_page = e.data.list.last_page, 
                t.data.total_page || (t.data.total_page = 0), t.setData({
                    recordsTeamList: e.data.list.data
                })) : wx.showToast({
                    icon: "none",
                    title: e.msg,
                    duration: 1500
                });
            },
            fail: function(a) {}
        });
    },
    onReady: function() {
        var a = wx.getStorageSync("langIndex");
        this.setData({
            language: a.en
        });
    },
    onShow: function() {},
    onHide: function() {},
    onUnload: function() {},
    onPullDownRefresh: function() {},
    getMoreData: function() {
        var t = this, e = "";
        1 == this.data.moreDataType ? e = a.getNetAddresss("plugin.interval-consumption.Frontend.controllers.records.get-personal") : 2 == this.data.moreDataType && (e = a.getNetAddresss("plugin.interval-consumption.Frontend.controllers.records.get-team")), 
        this.data.isLoadMore = !1, this.data.page >= this.data.total_page || (this.data.page = this.data.page + 1, 
        a._postNetWork({
            url: e,
            showToastIn: !1,
            data: {
                page: t.data.page
            },
            success: function(a) {
                var e = a.data;
                1 == e.result ? (myData = e.data.data, 1 == t.data.moreDataType ? t.setData({
                    recordsList: t.data.recordsList.concat(myData)
                }) : 2 == t.data.moreDataType && t.setData({
                    recordsTeamList: t.data.recordsTeamList.concat(myData)
                })) : (t.data.page = this.data.page - 1, t.data.isLoadMore = !1);
            },
            fail: function(a) {}
        }));
    },
    onReachBottom: function() {
        this.data.isLoadMore ? this.getMoreData() : console.log("没有更多数据");
    },
    onShareAppMessage: function() {}
});